import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

class TestPhotoView extends StatefulWidget {
  @override
  _TestPhotoViewState createState() => _TestPhotoViewState();
}

class _TestPhotoViewState extends State<TestPhotoView> {
  @override
  Widget build(BuildContext context) {
    List<PhotoViewGalleryPageOptions> options = [];
    for (int index = 1; index <= 8; index++) {
      options.add(_buildPhoto(index));
    }

    return Container(
      child: PhotoViewGallery(
        pageOptions: options,
        backgroundColor: Colors.black87,
      ),
    );
  }

  PhotoViewGalleryPageOptions _buildPhoto(int index) {
    return PhotoViewGalleryPageOptions(
      imageProvider: AssetImage("assets/car/car0$index.jpg"),
      heroTag: "tag$index",
      minScale: PhotoViewComputedScale.contained * 0.1,
      maxScale: PhotoViewComputedScale.covered * 2.0,
    );
  }
}
